import { Controller, Get, Query } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { Public } from '~/modules/auth/decorators/public.decorator';
import { ApiTenantHeader } from '~/common/decorators/api-header-tenant.decorator';
import { ModuleSwaggerTags } from '~/constants/modules.constant';
import { CategoryService } from '~/modules/category/category.service';
import { CategoryWithSymptoms } from '~/modules/category/category.types';
import { AuthUser } from '~/modules/auth/decorators/auth-user.decorator';

@ApiBearerAuth()
@ApiTags(ModuleSwaggerTags.CATEGORY)
@Controller('category')
export class MiniappCategoryController {
  constructor(private readonly categoryService: CategoryService) {}

  @Public()
  @Get()
  @ApiTenantHeader()
  @ApiOperation({ summary: '获取分类列表' })
  async getCategories(
    @AuthUser() user: IAuthUser,
    @Query('name') name?: string,
    @Query('code') code?: string
  ): Promise<CategoryWithSymptoms[]> {
		// 需要根据用户信息是否患有当前症状，并且给出指定的标识
    return await this.categoryService.findAllByUser(user?.uid, name, code);
  }
}